/* Handles application Start, Reset, Running, Stop

	Initializes objects

	Call Loop

	Call Render

	Call Exit

	i.e.

	App::OnExecute() {
	int App::OnExecute() 
	{
		if(OnInit() == false) 
		{
			return -1;
		}

		Event theEvents;

		while(Running) 
		{
			while(CheckForEvent(&Event)) 
			{
				OnEvent(&Event);
			}

			OnLoop();
			OnRender();
		}

		OnCleanup();

		return 0;
	}

	int main() 
	{
		App theApp; // Create App object, whose constructor initializes all objects

		return theApp.OnExecute();
	}

*/

#include "App.h"

App::App()
{

    Running = true;
}


int App::OnExecute() 
{
	if(OnInit() == false) 
	{
		return -1;
	}

	Event theEvents;

	while(Running) 
	{
		/* Get the input event */
		ReadConsoleInput( hstdin, &theEvents.event_instance, 1, &theEvents.count );

		// Checks for events and pass them each to event handler
		while(WaitForSingleObject( hstdin, 0 ) == WAIT_OBJECT_0)
		{
			
			OnEvent(theEvents.event_instance); // By reference?
		}

		OnLoop();
		OnRender();
	}

	OnCleanup();

	return 0;
}

int main() 
{
	App theApp; // Create App object, whose constructor initializes all objects

	return theApp.OnExecute();
}
